package com.blog.backend.controller;

import com.blog.backend.annotation.LoginAnno;
import com.blog.backend.req.AddTravelReq;
import com.blog.backend.req.TravelReq;
import com.blog.backend.resp.TravelResp;
import com.blog.backend.service.TravelManageService;
import com.blog.backend.utils.Result;
import com.blog.backend.vo.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/travel")
@Api("游记管理接口")
public class TravelManagerController {

    @Autowired
    private TravelManageService travelManageService;


    @PostMapping("/selectTravelList")
    @LoginAnno
    @ApiOperation("查询游记列表")
    public Result<PageResult<TravelResp>> selectTravelList(@RequestBody TravelReq req){
        PageResult<TravelResp> pageResult=travelManageService.selectTravelList(req);
        return Result.success(pageResult);
    }

    @PostMapping("/insertTravel")
    @LoginAnno
    @ApiOperation("新增游记")
    public Result<Boolean> insertTravel(@RequestBody AddTravelReq req){
        Boolean result=travelManageService.insertTravel(req);
        return Result.success(result);
    }

    @GetMapping("/selectTravelDetail")
    @LoginAnno
    @ApiOperation("查看游记详情")
    public Result<TravelResp> selectTravelDetail(@RequestParam String travelId){
        TravelResp resp = travelManageService.selectTravelDetail(travelId);
        return Result.success(resp);
    }

    @PostMapping("/updateTravelDetail")
    @LoginAnno
    @ApiOperation("修改游记内容")
    public Result<Boolean> updateTravelDetail(@RequestBody AddTravelReq req){
        Boolean result=travelManageService.updateTravelDetail(req);
        return Result.success(result);
    }

    @GetMapping("/deleteTravel")
    @ApiOperation("删除游记")
    @LoginAnno
    public Result<Boolean> deleteTravel(@RequestParam String travelId){
        Boolean result= travelManageService.deleteTravel(travelId);
        return Result.success(result);
    }
}
